package com.gxpt.app.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.gxpt.app.AppUtils;
import com.gxpt.app.Constant;
import com.gxpt.app.R;
import com.gxpt.app.base.ListBaseAdapter;
import com.gxpt.app.base.SuperViewHolder;
import com.gxpt.app.bean.fnewlist_bean;
import com.utils.ScreenUtils;
import com.utils.logger.Logger;
import com.utils.picasso.PicassoUtils;

/**
 * Created by Lzx on 2016/12/30.
 */

public class fnewlist_Adapter extends ListBaseAdapter<fnewlist_bean.fnewlist> {

    //列表图片
    int pic_view_width = 0;
    int pic_view_hight = 0;
    Context context;
    public fnewlist_Adapter(Context context) {
        super(context);
        this.context = context;
        int Sviewwidth  = ScreenUtils.getScreenWidth(context);//
        pic_view_width  = (Sviewwidth- AppUtils.dip2px(context,10*2))/4;
        pic_view_hight  = pic_view_width;

//        Logger.i("屏幕 = " + Sviewwidth);
//        Logger.i("宽 = " + pic_view_width);
//        Logger.i("高 = " + pic_view_hight);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_home_service_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        fnewlist_bean.fnewlist item = mDataList.get(position);

        TextView list_authen_type = holder.getView(R.id.list_authen_type);
        list_authen_type.setText(item.authen_type);

        TextView list_name = holder.getView(R.id.list_name);
        list_name.setText(item.shop_name);

        TextView list_service_range = holder.getView(R.id.list_service_range);
        list_service_range.setText(item.service_range);

        ImageView list_shop_logo = holder.getView(R.id.list_shop_logo);

        if(item.shop_logo.isEmpty()){
            PicassoUtils.Picasso_displayImage(context,R.mipmap.ic_launcher,pic_view_width,pic_view_hight,list_shop_logo);
        }else{
            PicassoUtils.Picasso_displayImage(context, Constant.IP+"/"+item.shop_logo,pic_view_width,pic_view_hight,list_shop_logo);
        }

        TextView list_city_name = holder.getView(R.id.list_city_name);
        list_city_name.setText(context.getResources().getString(R.string.txt_suozaidizhi)+" "+item.province_name);

    }
}
